//
//  XJCommunityHistoryCellTableViewCell.m
//  XinJiangMall
//
//  Created by RaoBo on 2018/6/1.
//  Copyright © 2018年 Tzyang. All rights reserved.
//

#import "XJCommunityHistoryCellTableViewCell.h"

@interface XJCommunityHistoryCellTableViewCell()
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;//张三
@property (weak, nonatomic) IBOutlet UILabel *state_nameLabel; // 已取消 待处理。。。。

@property (weak, nonatomic) IBOutlet UILabel *timeLabel; // 2018-06-01  14:27:39
@property (weak, nonatomic) IBOutlet UIButton *cancelButton; //取消申请 、删除
@end

@implementation XJCommunityHistoryCellTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}


- (void)configureName:(NSString *)name statusName:(NSString *)statusName timeStr:(NSString *)timeStr buttonTitle:(NSString *)btnTitle {
    self.nameLabel.text = name;
    self.state_nameLabel.text = statusName;
    self.timeLabel.text = [self stringFromTimeStamp:timeStr];
    
    [self.cancelButton setTitleColor:[UIColor blueColor] forState:(UIControlStateNormal)];
    [self.cancelButton setTitle:btnTitle forState:(UIControlStateNormal)];
}

// 时间戳转时间
- (NSString *)stringFromTimeStamp:(NSString *)stampStr {
    
    NSDateFormatter *fmt = [[NSDateFormatter alloc] init];
    [fmt setDateStyle:(NSDateFormatterMediumStyle)];
    [fmt setTimeStyle:(NSDateFormatterShortStyle)];
    fmt.dateFormat = @"yyyy-MM-dd HH:mm:ss";
    
    NSDate *date = [NSDate dateWithTimeIntervalSince1970:[stampStr doubleValue] / 1000.0];
    NSString *dateStr = [fmt stringFromDate:date];
    
    return dateStr;
}


#pragma mark - 点击事件

- (IBAction)clickButtonAction:(UIButton *)sender {
    if (self.clickButtonBlock) {
        self.clickButtonBlock();
    }
}

//
//(NSString )timeWithTimeIntervalString:(NSString )timeString
//format:(NSString )format {
//    // 格式化时间
//    NSDateFormatter formatter = [[NSDateFormatter alloc] init];
//    formatter.timeZone = [NSTimeZone timeZoneWithName:@"shanghai"];
//    [formatter setDateStyle:NSDateFormatterMediumStyle];
//    [formatter setTimeStyle:NSDateFormatterShortStyle];
//    [formatter setDateFormat:format];
//    // 毫秒值转化为秒
//    NSDate date = [NSDate dateWithTimeIntervalSince1970:[timeString doubleValue]/ 1000.0];
//    NSString dateString = [formatter stringFromDate:date];
//    return dateString;
//}


@end
